﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Moon.Common;

public partial class Admin_AdminLogin : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
    {
        GPI.Server.UserService server = new GPI.Server.UserService();
        string user=this.Login1.UserName;
        string pass=this.Login1.Password;
       string where=string.Format("AdminUser='{0}' and AdminPass='{1}'",user.HtmlEncode().RemoveSpaces(),pass.HtmlEncode().RemoveSpaces());
       if (server.GetList(where).Tables[0].Rows.Count > 0)
       {
           Session["User"] = user;
           Response.Redirect("Default.aspx");
       }
    }
    protected void Login1_LoginError(object sender, EventArgs e)
    {
        MessageBox.Show(this.Page, "不存在該用戶");

    }
    protected void Login1_LoggedIn(object sender, EventArgs e)
    {
        if (Session["User"] != null)
        {
            Response.Redirect("Default.aspx");
        }
    }
}
